<template>
  <div class="container">
    <h1>标签</h1>
    <div class="box">
      <span v-for="(item, index) in data" :key="index" @click="toIncludeTag(item)">{{ item.name }}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: "",
    };
  },
  methods: {
    toIncludeTag(item){
      this.$router.push({
        path:"/home/includetag",
        query:item
      })
    },
    getData() {
      this.$axios.post("api/tag/list").then((res) => {
        // console.log(res)
        this.data = res.data;
      });
    },
  },
  created() {
    this.getData();
  },
};
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  .box{
    width: 300px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    span{
        margin: 0px 4px 2px 0px;
        padding: 2px 5px 2px 5px;
        background-color: rgb(182, 248, 182);
        border-radius: 2px;
    }
    span:hover{
         background-color: rgb(125, 255, 125);
    }
  }
}
</style>